package com.example.game_forum.service;

import com.example.game_forum.dto.TCommentContentDto;
import com.example.game_forum.dto.TCommentDto;
import com.example.game_forum.repository.TCommentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TCommentService {

    @Autowired
    private TCommentRepository commentRepository;

    public List<TCommentContentDto> getCommentsByPostId(String postId) {
        return commentRepository.selectCommentsByPostId(postId);
    }

    @Transactional
    public void addComment(TCommentDto commentDto) {
        commentRepository.addComment(commentDto);
    }

    public void replyComment(TCommentDto commentDto,String parentId) {
        commentRepository.replyComment(commentDto,parentId);
    }

    @Transactional
    public void updateComment(String commentId, String comment) {
        commentRepository.updateComment(commentId, comment);
    }

    @Transactional
    public void deleteComment(String commentId) {
        commentRepository.deleteComment(commentId);
    }
}
